package com.nubia.interceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                //.allowedOrigins("http://192.168.2.109:8080","http://127.0.0.1:8848")
                .allowedOrigins("*")
                .allowedHeaders("*")
                .allowedMethods("*")
                .maxAge(30*1000);
    }
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
       registry.addInterceptor(new PublicInterceptor())
               .addPathPatterns("/**")
               .excludePathPatterns("/user/login",
                       "/user/register",
                       "/shop/getShopsList"
                       );
    }
}
